updating oE check_break

check_break

include console.e 
namespace console 
public function check_break() 

returns the number of Control+C and Control+Break key presses.

Returns:

An integer, the number of times that Control+C or Control+Break have been pressed since the last call to check_break, or since the beginning of the program if this is the first call.

Comments:

This is useful after you have called allow_break(0) which prevents Control+C or Control+Break from terminating your program. You can use check_break to find out if the user has pressed one of these keys. You might then perform some action such as a graceful shutdown of your program.

Neither Control+C nor Control+Break will be returned as input characters when you read the keyboard. You can only detect them by calling check_break.

Example 1:
k = get_key() 
if check_break() then  -- ^C or ^Break was hit once or more 
    temp = graphics_mode(-1) 
    puts(STDOUT, "Shutting down...") 
    save_all_user_data() 
    abort(1) 
end if 
See Also:

allow_break

Not Categorized, Please Help

Search



Quick Links

User menu

Not signed in.

Misc Menu